﻿using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Weblications.Sango.Entities;

namespace Pixysoft.Weblications.Sango.Environment
{
    class SysProfessionalRelationHelper
    {
        private static List<Sys_Professionalrelation> orms = new List<Sys_Professionalrelation>();

        public static void initialize()
        {
            orms = SettingHelper.GetNoebe().EntityNoebeCommand.Select<Sys_Professionalrelation>();

            LoggerHelper.Info("initialize Sys_Professionalrelation.countin {0}", orms.Count);
        }

        /// <summary>
        /// 获取职业之间的伤害加成 乘法
        /// </summary>
        /// <param name="fromserialcode"></param>
        /// <param name="toserialcode"></param>
        /// <returns></returns>
        public static double TryGetRelationDamageValue(long fromserialcode, long toserialcode)
        {
            Sys_Professionalrelation orm = TryGetRelation(fromserialcode, toserialcode);

            if (orm == null)
                return 1;

            return orm.Damagevalue;
        }

        protected static Sys_Professionalrelation TryGetRelation(long fromserialcode, long toserialcode)
        {
            foreach (Sys_Professionalrelation orm in orms)
            {
                if (orm.Fromserialcode != fromserialcode)
                    continue;

                if (orm.Toserialcode != toserialcode)
                    continue;

                return orm;
            }

            return null;
        }
    }
}
